//
//  JeemaaCommonHeader.h
//  UEAssistant
//
//  Created by mac on 2017/10/30.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#ifndef JeemaaCommonHeader_h
#define JeemaaCommonHeader_h
typedef NS_ENUM(NSInteger, JeemaaUserType){
    /** 个人用户*/
    UserTypePersonal,
    /** 企业用户*/
    UserTypeEnterprise,
};

#ifdef DEBUG
#define TGLog(FORMAT, ...) fprintf(stderr,"\n-------------------%s:%d----------------------\n%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])
#else
#define TGLog(...)
#endif

#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#define Base_Url [MJ_UserMessage sharedInstance].baseUrl

#define CurrentUserType [UserDefaults integerForKey:CurrentUserTypeKey]

#define userManager [MJ_UserMessage sharedInstance]
// UIScreen width
#define Screen_Width [UIScreen mainScreen].bounds.size.width
// UIScreen height
#define Screen_Height [UIScreen mainScreen].bounds.size.height


#define lineMainColor [UIColor colorWithHexString:@"#eeeeee"]

// if iPhone X
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
// status height
#define STATUS_BAR_HEIGHT (iPhoneX ? 44.f : 20.f)
// navi height
#define NAVIGATION_BAR_HEIGHT (iPhoneX ? 88.f : 64.f)
// tabBar height
#define TAB_BAR_HEIGHT (iPhoneX ? (49.f+34.f) : 49.f)
// navi excursion
#define NAVIGATION_EXCURSION (iPhoneX ? 24.f : 0.f)
//safe AreaAdapter method
#define HX_ViewSafeAreInsets(view) ({UIEdgeInsets insets; if(@available(iOS 11.0, *)) {insets = view.safeAreaInsets;} else {insets = UIEdgeInsetsZero;} insets;})

//AreaAdapter coefficient
#define Radio [FlexibleFrame ratio]
//AreaAdapter base screen
#define IPHONE_SCREEN CGSizeMake(375,667)
//font AreaAdapter
#define FLEXIBLE(NUM) [FlexibleFrame flexibleFloat:NUM]

//judge string isEmpty
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//judge array isEmpty
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//judge dictionary isEmpty
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
//judge id isEmpty
#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

//ShareCenter Model
#define shareData [ShareCenter shareModelData]
//shareDetails Model
#define detailsModel [DetailsModel shareDetailsModel]
//orderSingle
#define orderSingleton [OrderSingle shareOrderSingleData]
//user cache
#define UserDefaults [NSUserDefaults standardUserDefaults]
//AppDelegate
#define JAppDelegate (AppDelegate *)[[UIApplication sharedApplication] delegate]
//notificationCenter
#define JeemaaNotificationCenter  [NSNotificationCenter defaultCenter]

// colorWithRGB
#define RGB(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
//sky blue color
#define mainColor [UIColor colorWithHexString:@"#0084ff"]
//light gray color
#define mainGrayColor  RGB(143, 158, 172, 1)
//light red color
#define AlertRedColor RGB(231, 85, 83, 1)

//judge system version than "v"
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
//judge system version greater than 8.0
#define IOS8 ([[[UIDevice currentDevice] systemVersion] doubleValue] >=8.0 ? YES : NO)
//judge system version greater than 9.0
#define isIOS9 ([[UIDevice currentDevice].systemVersion intValue] >= 9 ? YES : NO)
//judge system version greater than 10.0
#define isIOS10 ([[UIDevice currentDevice].systemVersion intValue] >= 10 ? YES : NO)
#define JeemaaLogin [[MJ_UserMessage sharedInstance] userIsOnline]

//UserType
#define JeemaaPersonalUser(value) ([value integerValue] == 4 || [value integerValue] == 5 ? YES : NO )
#define JeemaaPersonaler ([[UserDefaults objectForKey:@"jeemaaUserTypeDefPath"] isEqualToString:@"personal"] ? YES : NO)

//without tabbar
#define IfHaveTabbar_Height ([[UserDefaults objectForKey:@"jeemaaUserTypeDefPath"] isEqualToString:@"personal"] ? 0.f : TAB_BAR_HEIGHT)
//tableview lessen height
#define tableview_lessen_height ([[UserDefaults objectForKey:@"jeemaaUserTypeDefPath"] isEqualToString:@"personal"] ? 0.f : 49.f)

//GCD
#define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//weak self
#define WeakSelf(weakSelf)  __weak __typeof(&*self)weakSelf = self;


#endif /* JeemaaCommonHeader_h */
